package org.javaboy.vhr.service;

import org.javaboy.vhr.bean.Position;
import org.javaboy.vhr.bean.RespBean;
import org.javaboy.vhr.mapper.PositionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class PositionService {

    @Autowired
    PositionMapper positionMapper;

    //查询所有职位
    public List<Position> getAllPositions(){
        return positionMapper.getAllPositions();
    }

    //添加职位
    public Integer addPosition(Position position) {
        //设置可用
        position.setEnabled(true);
        //设置添加的时间为当前时间
        position.setCreateDate(new Date());
        return positionMapper.insertSelective(position);
    }

    //修改职位
    public Integer updatePositions(Position position) {
        return positionMapper.updateByPrimaryKeySelective(position);
    }

    //删除职位
    public Integer deleteRositionById(Integer id) {
        return positionMapper.deleteByPrimaryKey(id);
    }

    //批量删除职位
    public Integer deletePositionsByIds(Integer[] ids) {
        return positionMapper.deletePositionsByIds(ids);
    }
}
